package d3_com.itheima.map;

import java.util.*;

public class MapDemo1 {
    public static void main(String[] args) {
        //1.准备80个学生的数据
        Random ra = new Random();
        List<String> data = new ArrayList<>();
        String[] select = {"A", "B", "C", "D"};
        for (int i = 0; i < 80; i++) {
            int Index = ra.nextInt(4);
            data.add(select[Index]);
        }
        //统计每个学生的投票结果
        Map<String, Integer> result = new HashMap<>();
        for (String s : data) {
            if (result.containsKey(s)) {
                result.put(s, result.get(s) + 1);
            } else {
                result.put(s, 1);
            }
        }
        System.out.println(result);
    }
}
